#define _CRT_SECURE_NO_WARNINGS

#include "process.h"

char str[] = "|\\-/";

void process_v1()
{
	int rate = 0;
	char arr[MAXSIZE] = { 0 };
	memset(arr, '\0', sizeof(arr));
	while (rate < MAXSIZE)
	{
		printf("[%-100s][%d%%][%c]\r", arr, rate, str[rate % strlen(str)]);
		fflush(stdout);
		Sleep(sleep_time);
		arr[rate++] = process_char;
	}
	printf("\n");
}

void process_v2(int rate)
{
	static char arr[MAXSIZE] = { 0 };
	//memset(arr,'\0',sizeof(arr));
	if (rate < MAXSIZE && rate >= 0)
	{
		printf("[%-100s][%d%%][%c]\r", arr, rate, str[rate % strlen(str)]);
		fflush(stdout);
		Sleep(sleep_time);
		if (rate < MAXSIZE - 1)
		{
			arr[rate - 1] = process_body;
			arr[rate] = process_head;
		}
		else
		{
			arr[rate] = process_body;
		}
	}
	//printf("\n");
}

//void process_v2(int rate)
//{
//	static char arr[MAXSIZE] = { 0 };
//	//memset(arr,'\0',sizeof(arr));
//	if (rate < MAXSIZE && rate >= 0)
//	{
//		printf("[%-100s][%d%%][%c]\r", arr, rate, str[rate % strlen(str)]);
//		fflush(stdout);
//		Sleep(sleep_time);
//		if (rate < MAXSIZE - 1)
//		{
//			arr[rate - 1] = process_body;
//			arr[rate] = process_head;
//		}
//		else
//		{
//			arr[rate] = process_body;
//		}
//	}
//	//printf("\n");
//}


